#include <bits/stdc++.h>
using namespace std;
const int N = 1010, M = 110;
int n, m1, m2;
int f[M][M];
int main() {
  cin >> n >> m1 >> m2;
  for (int i = 0; i < n; ++i) {
    int v1, v2, w;
    cin >> v1 >> v2 >> w;
    for (int j = m1; j >= v1; --j) {
      for (int k = m2; k >= v2; --k) {
        f[j][k] = max(f[j][k], f[j - v1][k - v2] + w);
      }
    }
  }
  cout << f[m1][m2] << endl;
}
